﻿cmake_minimum_required(VERSION 3.16)

project(CameraCommon
    VERSION 2.0.0
    DESCRIPTION "Camera 相关的公共代码。包括 ToolBarCamera 和 CameraImage 类。"
    LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Widgets LinguistTools Multimedia)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Widgets LinguistTools Multimedia)

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/..)

add_library(CameraCommon SHARED
    # CameraCommon/Camera_global.h
    include/CameraCommon/IndustryCamera.h
    # CameraCommon/IndustryCameraInfo.h
    src/DialogCameraSelect.cpp
    include/CameraCommon/DialogCameraSelect.h
    src/DialogCameraSelect.ui
    # CameraCommon/DialogCameraSetup.h
    # src/DialogCameraSetup.cpp
    # src/DialogCameraSetup.ui
    src/CameraImage.cpp
    include/CameraCommon/CameraImage.h
    src/CameraImage_RGB24.cpp
    include/CameraCommon/CameraImage_RGB24.h
    src/CameraImage_RGB32.cpp
    include/CameraCommon/CameraImage_RGB32.h
    src/PixelFormatConvert.cpp
    # CameraCommon/PixelFormatConvert.h
    src/ToolBarCamera.cpp
    include/CameraCommon/ToolBarCamera.h
    # CameraCommon/VideoFrame.h
    src/VideoFrame.cpp
    res/res.qrc
    include/CameraCommon/CameraLoader.h
    src/CameraLoader.cpp
    src/CameraFinder.cpp
    # CameraCommon/CameraFinder.h
)

#set(CMAKE_MODULE_PATH "C:/vcpkg/installed/x64-windows/share/ffmpeg")
find_package(FFmpeg REQUIRED)
target_include_directories(CameraCommon PUBLIC ${FFMPEG_INCLUDE_DIRS})
target_link_directories(CameraCommon PUBLIC ${FFMPEG_LIBRARY_DIRS})
target_link_libraries(CameraCommon PUBLIC ${FFMPEG_LIBRARIES})

target_link_libraries(CameraCommon PUBLIC Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Multimedia)
target_include_directories(CameraCommon PUBLIC ${PROJECT_SOURCE_DIR}/include)

target_compile_definitions(CameraCommon PRIVATE CAMERA_LIBRARY)

